package com.whp.listener_event;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.LifecycleProcessor;
import org.springframework.context.support.DefaultLifecycleProcessor;

/**
 * @author wanghp
 * @version 1.0
 * @date 2020/8/20 17:37
 */

public class TestListener implements ApplicationListener<ApplicationEvent>, LifecycleProcessor {
	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		System.out.println(event);
		System.out.println("-------------------进入自定义Event");
		if (event instanceof TestEvent) {
			((TestEvent) event).print();
		}

	}

	@Override
	public void onRefresh() {
		System.out.println("--------------进入自定义LifecycleProcessor的onRefresh方法");
	}

	@Override
	public void onClose() {
		System.out.println("--------------进入自定义LifecycleProcessor的onClose方法");
	}

	@Override
	public void start() {
		System.out.println("--------------进入自定义LifecycleProcessor的start方法");
	}

	@Override
	public void stop() {
		System.out.println("--------------进入自定义LifecycleProcessor的stop方法");
	}

	@Override
	public boolean isRunning() {
		return false;
	}
}
